package com.xzq.entity;

import java.util.List;

import org.springframework.beans.factory.annotation.Value;
import org.springframework.context.annotation.Scope;
import org.springframework.stereotype.Component;
/**
 * 分页类
 */
@Component
@Scope("prototype")
public class Page {
	@Value("#{pageSize.airSize}")
	public int AIRSIZE;
	@Value("#{pageSize.disSize}")
	public int DISSIZE;
	private int pageSize;//每页显示多少条数据
	private int allcount;//结果总条数
	private int allpage;//总页数
	private int nowpage = 1;//需要显示的页码
	private List getlist;//结果集合
	
	public int getPageSize() {
		return pageSize;
	}
	public void setPageSize(int pageSize) {
		this.pageSize = pageSize;
	}
	public int getAllpage() {
		return allpage;
	}
	public void setAllpage(int allcount) {
		if(allcount>0){
			this.allpage = (this.allcount%pageSize==0)?(this.allcount/pageSize):(this.allcount/pageSize+1);
			if(this.allpage<this.nowpage){
				this.nowpage = this.allpage;
			}
		}else{
			this.allpage = 0;
		}
	}
	public int getNowpage() {
		return nowpage;
	}
	public void setNowpage(int nowpage) {
		this.nowpage = nowpage;
	}
	public List getGetlist() {
		return getlist;
	}
	public void setGetlist(List getlist) {
		this.getlist = getlist;
	}
	public int getAllcount() {
		return allcount;
	}
	public void setAllcount(int allcount) {
		this.allcount = allcount;
	}
	public Page(int pageSize, int allcount, int allpage, int nowpage,
			List getlist) {
		this.pageSize = pageSize;
		this.allcount = allcount;
		this.allpage = allpage;
		this.nowpage = nowpage;
		this.getlist = getlist;
	}
	public Page() {
	}
	public Page(int nowpage) {
		this.nowpage = nowpage;
	}
	/**
	 * ��ȡҳ�����б�
	 * @param dopage ҳ������
	 * @param getallcount ��ѯ����������
	 * @param list ��ѯ�Ľ���б�
	 * @return ҳ�����-����������,��ҳ��,ÿҳ��ʾ������,����б�
	 */
	public Page setElement(Page dopage,int getallcount,List list,int pageSize){
		dopage.setPageSize(pageSize);
		dopage.setAllcount(getallcount);
		dopage.setAllpage(getallcount);
		dopage.setGetlist(list);
		return dopage;
	}

}
